import { FIRST_NAME, LAST_NAME } from "./dictionaries";

class NameCreate{
  constructor(){
    this.firstname = FIRST_NAME;
    this.lastname = LAST_NAME;
  }

  getRandomName(){
    return this.getFirstName() + this.getLastName();
  }

  getFirstName(){
    return this.firstname[~~(Math.random() * this.firstname.length)];
  }

  getLastName(num = null){
    let lastNum = num || (Math.random() > .49 ? 2 : 1);

    return new Array(lastNum).fill(1).map(() => this.lastname[~~(Math.random() * this.lastname.length)])
      .filter(i => i)
      .join('');
  }

  getCityName(suffix){
    return this.getLastName(2) + suffix;
  }
}

export const nameCreate = new NameCreate;